package org.keyyond.ms.gateway.controller;

import java.util.Map;

import org.keyyond.ms.gateway.util.MsRefreshRouteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.cloud.netflix.zuul.web.ZuulHandlerMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RefreshScope//用于刷新@Value标记的属性
public class MsGatewayController {

	@Autowired
    MsRefreshRouteService keyyondRefreshRouteService;
    @Autowired  
    ZuulHandlerMapping zuulHandlerMapping;  
  
    @GetMapping("/refreshRoute")  
    public String refresh() {  
    	keyyondRefreshRouteService.refreshRoute();  
        return "refresh success";  
    }  
  
    @RequestMapping("/watchRoute")  
    public Object watchNowRoute() {  
        //可以用debug模式看里面具体是什么  
        Map<String, Object> handlerMap = zuulHandlerMapping.getHandlerMap();  
        return handlerMap;  
    }
     
}
